package mse.eai.jbpm.dailyDigestProcess;

import java.util.Map;

import mse.eai.jbpm.confirmFriendshipRequest.PrepareFrienshipConfirmationNotification;

import org.jboss.logging.Logger;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;

public class IsWinnersListEmpty implements DecisionHandler {

	private static final Logger log = Logger
	.getLogger(IsWinnersListEmpty.class);
	
	// must return YES or NO
	public String decide(ExecutionContext context) throws Exception {
		
		String transition = null;
		log.info("Executing ---------->");

		try {
			Map<Integer,String> list = (Map<Integer,String>) context.getVariable("MapOfEmails");
			
			//log.info("Got from context: " + "MapOfEmails  = " + list);
			
			transition = (list.isEmpty() ? "YES" : "NO");
			
		} catch (Exception e) {
			log.error(e);
			transition = "YES";
		} 
		log.info("Transition chosen : " + transition);
		log.info("<--------------- Done");

		return transition;
	}
}